source "$METIS_HOME"metis-plugin.config

_pluginName=`basename $0 | sed -r 's/.sh$//'`
_pluginOutputDirectory="${pluginDir}${_pluginName}/"
mkdir ${_pluginOutputDirectory}

if [ -n "$1" ]; then
	timeout="$1"
else
	timeout=1200
fi
threads=5

query='select ipaddress,port from services where service = "http" and port !="443" and state = "open" and protocol = "tcp"'
cmd="java -jar ${m_dirbuster} -H -l ${m_dirbuster_words} -e asp,aspx,php,do,jsp -r ${_pluginOutputDirectory}\${1}-\${2}_http.txt -u http://\${1}:\${2}/ &> /dev/null"

"$pythonInterpreter" "$q2ex" -d "$database" -q "$query" -c "$cmd" -t "$threads" -T "$timeout" -o "$_pluginOutputDirectory" -e "$_pluginName" -L "$logginglevel" -O "$outputLog"

query='select ipaddress,port from services where (port ="443" and state = "open") or (service = "https" and state = "open")'
cmd="java -jar ${m_dirbuster} -H -l ${m_dirbuster_words} -e asp,aspx,php,do,jsp -r ${_pluginOutputDirectory}\${1}-\${2}_https.txt -u https://\${1}:\${2}/ &> /dev/null"

"$pythonInterpreter" "$q2ex" -d "$database" -q "$query" -c "$cmd" -t "$threads" -T "$timeout" -o "$_pluginOutputDirectory" -e "$_pluginName" -L "$logginglevel" -O "$outputLog"
